home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWString / Include / FWBndStr.h next >
Encoding:
Text File  |  1995-11-08  |  4.9 KB  |  161 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWBndStr.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWBNDSTR_H
  11. #define FWBNDSTR_H
  12.  
  13. #ifndef FWSTRS_H
  14. #include "FWStrs.h"
  15. #endif
  16.  
  17. #if FW_LIB_EXPORT_PRAGMAS
  18. #pragma lib_export on
  19. #endif
  20.  
  21. //========================================================================================
  22. //    CLASS FW_CBoundedString
  23. //========================================================================================
  24.  
  25. class FW_CLASS_ATTR FW_CBoundedString : public FW_CString
  26. {
  27.   public:
  28.  
  29.     FW_DECLARE_CLASS
  30.     
  31.     virtual ~ FW_CBoundedString();
  32.     FW_CBoundedString(FW_ByteCount stringSize, FW_Byte* storagePointer);
  33.     FW_CBoundedString(FW_ByteCount charWidth, FW_ByteCount stringSize, FW_Byte* storagePointer);
  34.     
  35.     FW_CString& operator=(const FW_CString& string);
  36.     FW_CString& operator=(const FW_Char* string);
  37.     
  38.     virtual FW_ByteCount GrowCapacity(FW_ByteCount capacityNeeded);
  39.         // Return tCapacity*sizeof(FW_Char).  The capacity of bounded strings never changes.
  40.  
  41.  private:
  42.      FW_ByteCount    fStringSize;
  43. };
  44.  
  45. //========================================================================================
  46. //    CLASS FW_CString32
  47. //========================================================================================
  48.  
  49. class FW_CLASS_ATTR FW_CString32 : public FW_CBoundedString
  50. {
  51.   public:
  52.  
  53.     FW_DECLARE_CLASS
  54.     
  55.     virtual ~ FW_CString32();
  56.     FW_CString32();
  57.     FW_CString32(const FW_CString32 &string);
  58.     FW_CString32(const FW_CString &string);
  59.     FW_CString32(const FW_Char *items, FW_CharacterCount numberItems);
  60.     FW_CString32(const FW_Char *items);
  61.     FW_CString32(FW_ByteCount charWidth);
  62.     
  63.     FW_CString& operator=(const FW_CString32 &string);
  64.     
  65.   private:
  66.     FW_Byte     fStorage[32 * sizeof(FW_Char) + FW_kMedianCharacterSize];
  67.         // Must leave room for a NUL word
  68. };
  69.  
  70. //========================================================================================
  71. //    CLASS FW_CString255
  72. //========================================================================================
  73.  
  74. class FW_CLASS_ATTR FW_CString255 : public FW_CBoundedString
  75. {
  76.   public:
  77.  
  78.     FW_DECLARE_CLASS
  79.     
  80.     virtual ~ FW_CString255();
  81.     FW_CString255();
  82.     FW_CString255(const FW_CString255 &string);
  83.     FW_CString255(const FW_CString &string);
  84.     FW_CString255(const FW_Char *items, FW_CharacterCount numberItems);
  85.     FW_CString255(const FW_Char *items);
  86.     FW_CString255(FW_ByteCount charWidth);
  87.     
  88.     FW_CString& operator=(const FW_CString255 &string);
  89.     
  90.   private:
  91.     FW_Byte     fStorage[255 * sizeof(FW_Char) + FW_kMedianCharacterSize];
  92.         // Must leave room for a NUL word
  93. };
  94.  
  95. //========================================================================================
  96. //    CLASS FW_CBoundedString inlines
  97. //========================================================================================
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    FW_CBoundedString::operator=
  101. //----------------------------------------------------------------------------------------
  102.  
  103. inline FW_CString& FW_CBoundedString::operator=(const FW_CString& string)
  104. {
  105.     fCharWidth = string.GetCharWidth();
  106.     ReplaceAll(string);
  107.     return *this;
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    FW_CBoundedString::operator=
  112. //----------------------------------------------------------------------------------------
  113.  
  114. inline FW_CString& FW_CBoundedString::operator=(const FW_Char* string)
  115. {
  116.     ReplaceAllBytes(string, FW_StringLength(string));
  117.     return *this;
  118. }
  119.  
  120. //========================================================================================
  121. //    CLASS FW_CString32 inlines
  122. //========================================================================================
  123.  
  124. //----------------------------------------------------------------------------------------
  125. //    FW_CString32::operator=
  126. //----------------------------------------------------------------------------------------
  127.  
  128. inline FW_CString& FW_CString32::operator=(const FW_CString32& string)
  129. {
  130.     if (&string != this)
  131.     {
  132.         fCharWidth = string.GetCharWidth();
  133.         ReplaceAll(string);
  134.     }
  135.     return *this;
  136. }
  137.  
  138. //========================================================================================
  139. //    CLASS FW_CString255 inlines
  140. //========================================================================================
  141.  
  142. //----------------------------------------------------------------------------------------
  143. //    FW_CString255::operator=
  144. //----------------------------------------------------------------------------------------
  145.  
  146. inline FW_CString& FW_CString255::operator=(const FW_CString255& string)
  147. {
  148.     if (&string != this)
  149.     {
  150.         fCharWidth = string.GetCharWidth();
  151.         ReplaceAll(string);
  152.     }
  153.     return *this;
  154. }
  155.  
  156. #if FW_LIB_EXPORT_PRAGMAS
  157. #pragma lib_export off
  158. #endif
  159.  
  160. #endif
  161.